package com.firesrc.service.server;

import java.util.concurrent.Callable;

import com.firesrc.bean.ProcessorBean;
import com.firesrc.util.EncryptUtil;
import com.firesrc.util.SystemConfigConstant;

public class ProcessDataCallable implements Callable<String> {
  private final ProcessorBean processorBean;

  public ProcessDataCallable(ProcessorBean processorBean) {
    this.processorBean = processorBean;
  }

  @Override
  public String call() throws Exception {
    String result = "";
    if (SystemConfigConstant.IMPORT_RECORD.equals(processorBean.getType())) {
      ProcessDataCommand importCommand = new ImportRecordCommand();
      result = importCommand.process(processorBean);
    }
    if (SystemConfigConstant.FETCH_KEYWORD.equals(processorBean.getType())) {
      ProcessDataCommand importCommand = new FetchKeywordRecordCommand();
      result = importCommand.process(processorBean);
    }
    String encryptString = EncryptUtil.encryptString(result);
    return encryptString;
  }
}